<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript">
		
		window.onload = function(){
			var oDiv = document.getElementById('div1');
			function fnTimego(){
				var sNow = new Date();
					
				var iYear = sNow.getFullYear();
					
				var iMonth = sNow.getMonth() + 1;

				var iDate = sNow.getDate();

				var iWeek = sNow.getDay();

				var iHour = sNow.getHours();

				var iMinute = sNow.getMinutes();

				var iSecond = sNow.getSeconds();

				var sTr = '当前时间是: ' + iYear + '年' + iMonth + '月' + iDate + '日' + ' ' + fnToweek(iWeek) + ' ' +fnTodouble(iHour) + ':' +fnTodouble(iMinute) + ':' + fnTodouble(iSecond);

				oDiv.innerHTML = sTr;}

			fnTimego();	
			setInterval(fnTimego,1000);

			function fnToweek(n){
				switch(n){
					case 0:return '星期日';
					case 1:return '星期一';
					case 2:return '星期二';
					case 3:return '星期三';
					case 4:return '星期四';
					case 5:return '星期五';
					case 6:return '星期六';
				}
			}

			function fnTodouble(n){
				if(n<10)
					return '0' + n;
				else 
					return n;
			}

		}
	</script>

	<style type="text/css">
		.box{
			font-size: 30px;
			color:purple;
			text-align: center;
		}
	</style>

</head>
<body>
	<div class="box" id="div1"></div>
</body>
</html>